package fr.inserm.u915.organifooyi.web;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.Principal;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Set;

import javax.servlet.AsyncContext;
import javax.servlet.DispatcherType;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletInputStream;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.http.Part;

import fr.inserm.u915.organifooyi.lang.Cast;


public class HttpServletRequestWrapper
	implements HttpServletRequest
	{
	private HttpServletRequest _delegate;

	public HttpServletRequestWrapper(HttpServletRequest delegate)
		{
		this._delegate=delegate;
		}
	
	public HttpServletRequest getDelegate()
		{
		return this._delegate;
		}
	
	public Set<String> getParameterNamesAsSet()
		{
		Set<String> set=new HashSet<String>();
		Enumeration<?> e=this.getParameterNames();
		while(e.hasMoreElements())
			{
			set.add(e.nextElement().toString());
			}
		return set;
		}
	
	public <T> T getAttribute(String attName,Class<T> clazz)
		{
		return clazz.cast(getAttribute(attName));
		}

	public String getParameter(String param,Object defaultValue)
		{
		String s= getDelegate().getParameter(param);
		return (s==null?String.valueOf(defaultValue==null?"":defaultValue):s);
		}

	public <T> T getParameter(String param,Class<T> clazz)
		{
		String s= getParameter(param);
		if(s==null) return null;
		return Cast.cast(s, clazz);
		}
	public <T> T getParameter(String param,Class<T> clazz,T defaultValue)
		{
		T t= getParameter(param, clazz);
		return t==null?defaultValue:t;
		}

	
	
	public boolean authenticate(HttpServletResponse arg0) throws IOException,
			ServletException {
		return getDelegate().authenticate(arg0);
	}

	public AsyncContext getAsyncContext() {
		return getDelegate().getAsyncContext();
	}

	public Object getAttribute(String arg0) {
		return getDelegate().getAttribute(arg0);
	}

	public Enumeration<String> getAttributeNames() {
		return getDelegate().getAttributeNames();
	}

	public String getAuthType() {
		return getDelegate().getAuthType();
	}

	public String getCharacterEncoding() {
		return getDelegate().getCharacterEncoding();
	}

	public int getContentLength() {
		return getDelegate().getContentLength();
	}

	public String getContentType() {
		return getDelegate().getContentType();
	}

	public String getContextPath() {
		return getDelegate().getContextPath();
	}

	public Cookie[] getCookies() {
		return getDelegate().getCookies();
	}

	public long getDateHeader(String arg0) {
		return getDelegate().getDateHeader(arg0);
	}

	public DispatcherType getDispatcherType() {
		return getDelegate().getDispatcherType();
	}

	public String getHeader(String arg0) {
		return getDelegate().getHeader(arg0);
	}

	public Enumeration<String> getHeaderNames() {
		return getDelegate().getHeaderNames();
	}

	public Enumeration<String> getHeaders(String arg0) {
		return getDelegate().getHeaders(arg0);
	}

	public ServletInputStream getInputStream() throws IOException {
		return getDelegate().getInputStream();
	}

	public int getIntHeader(String arg0) {
		return getDelegate().getIntHeader(arg0);
	}

	public String getLocalAddr() {
		return getDelegate().getLocalAddr();
	}

	public String getLocalName() {
		return getDelegate().getLocalName();
	}

	public int getLocalPort() {
		return getDelegate().getLocalPort();
	}

	public Locale getLocale() {
		return getDelegate().getLocale();
	}

	public Enumeration<Locale> getLocales() {
		return getDelegate().getLocales();
	}

	public String getMethod() {
		return getDelegate().getMethod();
	}

	public String getParameter(String arg0) {
		return getDelegate().getParameter(arg0);
	}

	public Map<String, String[]> getParameterMap() {
		return getDelegate().getParameterMap();
	}

	public Enumeration<String> getParameterNames() {
		return getDelegate().getParameterNames();
	}

	public String[] getParameterValues(String arg0) {
		return getDelegate().getParameterValues(arg0);
	}

	public Part getPart(String arg0) throws IOException, IllegalStateException,
			ServletException {
		return getDelegate().getPart(arg0);
	}

	public Collection<Part> getParts() throws IOException,
			IllegalStateException, ServletException {
		return getDelegate().getParts();
	}

	public String getPathInfo() {
		return getDelegate().getPathInfo();
	}

	public String getPathTranslated() {
		return getDelegate().getPathTranslated();
	}

	public String getProtocol() {
		return getDelegate().getProtocol();
	}

	public String getQueryString() {
		return getDelegate().getQueryString();
	}

	public BufferedReader getReader() throws IOException {
		return getDelegate().getReader();
	}

	@Deprecated
	public String getRealPath(String arg0) {
		return getDelegate().getRealPath(arg0);
	}

	public String getRemoteAddr() {
		return getDelegate().getRemoteAddr();
	}

	public String getRemoteHost() {
		return getDelegate().getRemoteHost();
	}

	public int getRemotePort() {
		return getDelegate().getRemotePort();
	}

	public String getRemoteUser() {
		return getDelegate().getRemoteUser();
	}

	public RequestDispatcher getRequestDispatcher(String arg0) {
		return getDelegate().getRequestDispatcher(arg0);
	}

	public String getRequestURI() {
		return getDelegate().getRequestURI();
	}

	public StringBuffer getRequestURL() {
		return getDelegate().getRequestURL();
	}

	public String getRequestedSessionId() {
		return getDelegate().getRequestedSessionId();
	}

	public String getScheme() {
		return getDelegate().getScheme();
	}

	public String getServerName() {
		return getDelegate().getServerName();
	}

	public int getServerPort() {
		return getDelegate().getServerPort();
	}

	public ServletContext getServletContext() {
		return getDelegate().getServletContext();
	}

	public String getServletPath() {
		return getDelegate().getServletPath();
	}

	public HttpSession getSession() {
		return getDelegate().getSession();
	}

	public HttpSession getSession(boolean arg0) {
		return getDelegate().getSession(arg0);
	}

	public Principal getUserPrincipal() {
		return getDelegate().getUserPrincipal();
	}

	public boolean isAsyncStarted() {
		return getDelegate().isAsyncStarted();
	}

	public boolean isAsyncSupported() {
		return getDelegate().isAsyncSupported();
	}

	public boolean isRequestedSessionIdFromCookie() {
		return getDelegate().isRequestedSessionIdFromCookie();
	}

	public boolean isRequestedSessionIdFromURL() {
		return getDelegate().isRequestedSessionIdFromURL();
	}

	@Deprecated
	public boolean isRequestedSessionIdFromUrl() {
		return getDelegate().isRequestedSessionIdFromUrl();
	}

	public boolean isRequestedSessionIdValid() {
		return getDelegate().isRequestedSessionIdValid();
	}

	public boolean isSecure() {
		return getDelegate().isSecure();
	}

	public boolean isUserInRole(String arg0) {
		return getDelegate().isUserInRole(arg0);
	}

	public void login(String arg0, String arg1) throws ServletException {
		getDelegate().login(arg0, arg1);
	}

	public void logout() throws ServletException {
		getDelegate().logout();
	}

	public void removeAttribute(String arg0) {
		getDelegate().removeAttribute(arg0);
	}

	public void setAttribute(String arg0, Object arg1) {
		getDelegate().setAttribute(arg0, arg1);
	}

	public void setCharacterEncoding(String arg0)
			throws UnsupportedEncodingException {
		getDelegate().setCharacterEncoding(arg0);
	}

	public AsyncContext startAsync() {
		return getDelegate().startAsync();
	}

	public AsyncContext startAsync(ServletRequest arg0, ServletResponse arg1) {
		return getDelegate().startAsync(arg0, arg1);
	}
	
	
	}
